trigger OnCaseUpdate on Case (before insert,before update) {
    try {
        if ( (Case_Trigger.firstTime == False) ||
        	 (EntitlementList.getCaseTriggersDisabledState() == True) ) 
        {
            System.debug('>>> OnCaseX trigger stub will not run.');
        } 
        else 
        {
            Case_Trigger.firstTime = false;
            
            // Default Entitlement
            if (trigger.isInsert) {
                CaseInit.BulkExtractContacts(trigger.new);
                for(Case c:trigger.new) { if (c.Entitlement__c==null) CaseInit.SetDefEnt(c,Case_Trigger.l4c); }
            }
            
            // Get SP-Entitlement pairs
            if ((trigger.isInsert)||(trigger.isUpdate)) {
                for(Case c:trigger.new) { if (c.Entitlement__c!=null) CaseInit.EntIdSet.add(c.Entitlement__c); }
                CaseInit.BulkExtractEntSPs(CaseInit.EntIdSet);
            }
            
            // Do regular trigger work
            if (trigger.isInsert) {
                System.debug('>>> OnCaseX:  entering trigger stub for BEFORE INSERT');
                Case_Trigger.DoBeforeInsertBatch( trigger.new ); 
            } else {
                System.debug('>>> OnCaseX:  entering trigger stub for BEFORE UPDATE');
                Case_Trigger.DoBeforeUpdateBatch( trigger.new, trigger.old );
            }
        }
    } catch (Exception e){
        System.debug('>>> Last chance catch in OnCaseX: ' + e.getMessage());
    } finally {
        System.debug('>>> OnCaseX:  leaving trigger stub');
    }
}